<template>
  <div class="container_detail word-edit">
    <div class="header">
      <p>意见反馈>查看意见</p>
      <el-button class="link" type="primary">
        <router-link :to="{path:'viewList',query: { pageIndex: currentPage }}" style="color: #fff;">返回</router-link>
      </el-button>
    </div>
    <div class="main">
      <el-form :model="user" :rules="rules" ref="user" label-width="120px" class="">
        <div class="list">
          <div class="title">查看意见</div>
          <el-form-item prop="storeName">
            <div class="item">
              <div class="item-key">发表编号:</div>
              <div class="item-value">
                {{user.id}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="brandId">
            <div class="item">
              <div class="item-key">发表人/所属集团:</div>
              <div class="item-value">
                {{user.esShopUserCoreDTO.trueName?user.esShopUserCoreDTO.trueName:user.esShopUserCoreDTO.userName}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">发表手机号/定制账号:</div>
              <div class="item-value">
               {{user.esShopUserCoreDTO.mobile}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">标题:</div>
              <div class="item-value">
               {{user.title}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">反馈意见:</div>
              <div class="item-value">
               {{user.detail}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">发表时间:</div>
              <div class="item-value">
               {{user.gmtCreated}}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">回复时间:</div>
              <div class="item-value">
               {{user.replyTime }}
              </div>
            </div>
          </el-form-item>
          <el-form-item prop="userName">
            <div class="item">
              <div class="item-key">回复内容:</div>
              <div class="item-value">
                <el-input
                v-if="replyState"
                type="textarea"
                style="width:400px"
                :rows="6"
                placeholder="请输入内容"
                v-model="replyDetail">
              </el-input>
              <div v-else>{{user.replyDetail}}</div>
              </div>
            </div>
          </el-form-item>
          <el-form-item>
              <el-button
                type="primary"
                @click="replyBtn"
                style="margin-left:40%;margin-top:20px"
              >{{!replyState?'回复':'保存'}}</el-button>
              <el-button class="link" type="primary">
                <router-link :to="{path:'viewList',query: { currentPage: currentPage }}" style="color: #fff;">返回</router-link>
            </el-button>
          </el-form-item>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
let CONSTANT = require("../../constant/constant.js");
let common = require("../../common.js");

export default {
  data() {
    return {
      replyState:false,
      replyDetail:'',
      id: "",
      info: "",
      // 返回 导航页码
      currentPage: 1,
      user: {
        "brandId": "",
        "brandName": "",
        "id": "",
        "psw": "",
        "psw2": "",
        "storeName": "",
        "userName": ""
     }
    };
  },
  mounted() {
    this.id = this.$router.currentRoute.query.id;
    this.currentPage = this.$router.currentRoute.query.pageIndex
      ? this.$router.currentRoute.query.pageIndex
      : 1;
    this.getDetail();
  },
  methods: {
    replyBtn(){
      if(this.replyState){
         let url = CONSTANT.URL.LIST.saveEsAdvice;
         let user =  this.user
        let data = {
          adminIsRead:'y',
          "detail":user.detail,
          "id": user.id,
          "replyDetail": this.replyDetail,
          "title": user.title,
          "userId":user.esShopUserCoreDTO.userId,
        }
        common.requestAjax(url, JSON.stringify(data), null, res => {
          this.$message({
            type: "success",
            message: "回复成功!"
          });
          this.getDetail();
          this.replyState = false
        });

      }else{
        this.replyState = true
      }
    },
     getDetail() {
      let url = CONSTANT.URL.LIST.findEsAdviceById;
      let data = { id: this.id }
      common.requestAjax(url, JSON.stringify(data), null, res => {
        this.user = res.data.bussData;
      });
    }
  }
};
</script>
<style lang="scss">
.word-edit {
  .el-form-item {
    margin: 0px;
    
  }

  .item-value {
    .el-input {
      width: 50%;
    }
    .el-select {
      width: 50%;
      .el-input {
        width: 100%;
      }
    }
  }
  .el-form-item__content {
    margin: 0px !important;
  }
}
</style>

